<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .success {
            border: 5px solid green;
            width: 100px;
            height: 100px;
        }

        .error{
            background-color: red;
        }

        .test1{
            color: darkmagenta;
        }

        .test2{
            color: fuchsia;
        }
    </style>
</head>
<body>

<div id="div1">
  <!--绑定样式-->
    <div v-bind:class="[successClass,errorClass,{test1:isTest1}]">测试1</div>
    <div v-bind:class="arrClass">测试2</div>
    <div v-bind:class="objClasses">测试3</div>
    <div class="test2" v-bind:class="objClasses">测试4</div>

    <button @click="handler">修改样式</button>

</div>

<script>

    const vueObj = new Vue({
        el:'#div1',
        data: {

            successClass: 'success',
            errorClass: 'error',
            //通过true和false来控制样式显示    通过单个样式控制
            isTest1: true,

            //通过数组控制
            arrClass: ['success', 'error'],

            //通过对象控制
            objClasses:{
                success: true,
                error: true,

            }


        },
        methods:{
            handler:function(){
                //取消样式
                this.objClasses.error = false;
            },
        }
    });
</script>
</body>
</html>